/*
 * 
 */
package com.platform.common.utils;

import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * <pre>
 * 功能：json格式化工具工厂
 * </pre>
 * 
 * @author wei.gao
 */
public class GsonUtils {
	
	/*
	 * 单例
	 */
	private static GsonUtils instance = null;
	public static Gson getInstance(){
		if(instance == null){
			synchronized (GsonUtils.class) {
				if(instance == null){
					instance = new GsonUtils();
				}
			}
		}
		return instance.gson;
	}
	
	private Gson gson = null;
	public GsonUtils() {
		gson = new GsonBuilder()
			.disableHtmlEscaping()
			.disableInnerClassSerialization()
			.setDateFormat("yyyy-MM-dd HH:mm:ss")
			.setFieldNamingPolicy(FieldNamingPolicy.IDENTITY)
			.serializeNulls()
			.setPrettyPrinting()
			.create();
	}
}
